package com.abiao.shop.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

/**
 * @Description: MQReceiver 消息接收者（消费者）(学习记录，与项目无关)
 * @Author: AB
 * @Date: 2021-07-21
 * @Version:v1.0
 */
@Slf4j
@Service
public class MQReceiver {

    //direct
    @RabbitListener(queues = MQConfig.QUEUE_NAME)
    public void receive(String msg){
        log.info("MQReceiver :"+msg);
    }

    //topic
    @RabbitListener(queues = MQConfig.QUEUE_1)
    public void receiveQ1(String msg){
        log.info("Queue1 received:"+msg);
    }
    @RabbitListener(queues = MQConfig.QUEUE_2)
    public void receiveQ2(String msg){
        log.info("Queue2 received:"+msg);
    }
    //header
    @RabbitListener(queues = MQConfig.HEADER_QUEUE)
    public void receiveQ2(byte[] msg){
        log.info("headerQueue received:"+new String(msg));
    }

}
